package com.ibm.cps.message;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.KryoSerializable;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;

public class OptimizedParsedDataMessage extends ParsedDataMessage implements
		KryoSerializable {

	private String sourceProcessorid;

	private ParsedDataMessage message;

	public OptimizedParsedDataMessage(int len) {
		super(len);
	}

	public OptimizedParsedDataMessage(ParsedDataMessage message, String sourceid) {
		this(message.getValueCount());
		tsKey = message.getTsKey();
		values = message.getObjectValues();
		timestamp = message.getTimestamp();
		this.sourceProcessorid = sourceid;
	}


	@Override
	public void write(Kryo kryo, Output output) {
		output.writeString(sourceProcessorid);
		kryo.writeObject(output, message);
	}

	@Override
	public void read(Kryo kryo, Input input) {
		sourceProcessorid = input.readString();
		message = kryo.readObject(input, ParsedDataMessage.class);
	}

	public String getSourceProcessorid() {
		return sourceProcessorid;
	}

	public void setSourceProcessorid(String soureProcessorid) {
		this.sourceProcessorid = soureProcessorid;
	}

	public ParsedDataMessage getMessage() {
		return message;
	}

	public void setMessage(ParsedDataMessage message) {
		this.message = message;
	}

}
